<?php
	$realstate_vars = array(); 
	if (!isset($_GET['rid'])) $rid=NULL; else $rid=$_GET['rid'];
	if ($rid==NULL) if (!isset($_POST['rid'])) $rid=NULL; else $rid=$_POST['rid'];
	if ($rid!=NULL){
		$data['rproduct']=$realstateclass->get_product_fields_with_data($rid, $_SESSION['lang']);
		$price_mod = $realstateclass->get_price_mod_by_product_id($rid, 'realstate_product');
		if ($price_mod != 0) $data['rproduct']['price_mod']=$price_mod;
		$data['rproduct']['id'] = $rid;
	}

	unset($realstate_vars);
	
 	if (!isset($_GET['cache_id'])) $product_cache_id=NULL; else $product_cache_id=$_GET['cache_id'];
	if ($product_cache_id==NULL) if (!isset($_POST['cache_id'])) $product_cache_id=NULL; else $product_cache_id=$_POST['cache_id'];

	if ((is_array($query)) && (count($query) > 0)) {
		if (isset($query['group_id']) && (intval($query['group_id']) > 0)){
			unset($query['group_id']);
			$tmp = $realstateclass->products_search($query, "0", intval($query['group_id']));
		} else $tmp = $realstateclass->products_search($query, "0");
		$data['search']['products'] = $tmp['products'];
		$data['search']['cache_id'] = $tmp['product_search_cache_id'];
		$data['search']['query'] = $query;
		$get_str = "";
		foreach($_GET as $key=>$value) $get_str .= "&".$key."=".$value;
		header ("location: ".$setupdata['base_href']."/index.php?cache_id=".$data['search']['cache_id']."&module=realstate".$get_str);
	} elseif ($product_cache_id != NULL){
		$tmp = $realstateclass->products_search(array(), $product_cache_id);
		$data['search']['products'] = $tmp['products'];
		$data['search']['cache_id'] = $tmp['product_search_cache_id'];
		$data['search']['query'] = $tmp['query'];
	} else $data['search']['products'] = "";
	
	if ($act == 'off_add') {
		if (isset($_POST["selectable_discount_id"])) $selectable_discount_id = $_POST["selectable_discount_id"];
		else $selectable_discount_id = 0;
		if (isset($_SESSION['select_off']) && ($_SESSION['select_off'] != $selectable_discount_id)){
			$_SESSION['select_off'] = $selectable_discount_id;
			$realstateclass->get_all_offs();
		} else $_SESSION['select_off'] = $selectable_discount_id;
	}
?>